//
//  Utility.h
//  MandarinDucks
//
//  Created by 艾特—iOS on 5/12/16.
//  Copyright © 2016年 艾特_iOS. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

#import "iToast.h"
#import "UserManager.h"
//#import "Config.h"
//#import "MBProgressHUD.h"
#import "AFNetworking.h"
#import "MJRefresh.h"
#import "UIImageView+WebCache.h"

#import "AppDelegate.h"
//#import "AccountManager.h"
//#import "MandarinDucks.h"

//#import "RootTableViewCell.h"
//#import "RootCollectionViewCell.h"

//#import "LoginViewController.h"

//#define COLOR(x,y,z) [UIColor colorWithRed:x/255.0 green:y/255.0 blue:z/255.0 alpha:1]
//判断字符串是否为空
#define isStringEmpty(a) ([a isEqual:[NSNull null]] || a == nil || [a isEqualToString:@""])
//[a isEqual:[NSNull null]] || a == nil || [a isEqualToString:@""]

//判断对象是否为空
#define isObjectEmpty(a) ([a isEqual:[NSNull null]] || a == nil)

//判断数组是否为空
#define isArrayEmpty(a) ([a isEqual:[NSNull null]] || a == nil || a.count == 0)
#define BaseColor [UIColor colorWithRed:255.0/255 green:79/255.0 blue:133/255.0 alpha:1]
#define IMG(x) [UIImage imageNamed:x]

#define kScreanWidth [UIScreen mainScreen].bounds.size.width
#define kScreanHeight [UIScreen mainScreen].bounds.size.height
#define kStatusHeight [UIApplication sharedApplication].statusBarFrame.size.height
#define knaviBarHeight self.navigationController.navigationBar.frame.size.height
#define kTabbarHeight self.tabBarController.tabBar.frame.size.height

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

// 聊天
#define ALERT(msg)  [[[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:nil \
cancelButtonTitle:@"确定" otherButtonTitles:nil,nil] show]

#define App_Delegate ((AppDelegate*)[[UIApplication sharedApplication]delegate])

#define App_RootCtr  [UIApplication sharedApplication].keyWindow.rootViewController

#define WEAKSELF __weak typeof(self) weakSelf = self;

#define ICRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0]

#define BACKGROUNDCOLOR   XZRGB(0xf4f1f1)
#define SEARCHBACKGROUNDCOLOR  [UIColor colorWithRed:(110.0)/255.0 green:(110.0)/255.0 blue:(110.0)/255.0 alpha:0.4]


#define EMOJI_CODE_TO_SYMBOL(x) ((((0x808080F0 | (x & 0x3F000) >> 4) | (x & 0xFC0) << 10) | (x & 0x1C0000) << 18) | (x & 0x3F) << 24);

#define kDiscvoerVideoPath @"Download/Video"  // video子路径
#define kChatVideoPath @"Chat/Video"  // video子路径
#define kVideoType @".mp4"        // video类型
#define kRecoderType @".wav"


#define kChatRecoderPath @"Chat/Recoder"
#define kRecodAmrType @".amr"

#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
// 网络加载错误原因
#define AFTfailStr @"请求数据失败，请重新请求"

// 单一弹出窗
#define alert(string, detail) UIAlertController *alertController = [UIAlertController alertControllerWithTitle:string message:detail preferredStyle:UIAlertControllerStyleAlert]; \
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleCancel handler:nil]; \
[alertController addAction:okAction]; \
[self presentViewController:alertController animated:YES completion:nil];

// 用户账号密码
#define UserAccount @"account"
#define UserPwd @"password"

/**
 *   QQ授权相关的字段
 *
 ****/
/** 发表一条说说到QQ空间(<b>需要申请权限</b>) */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_TOPIC;

/** 发表一篇日志到QQ空间(<b>需要申请权限</b>) */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_ONE_BLOG;

/** 创建一个QQ空间相册(<b>需要申请权限</b>) */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_ALBUM;

/** 上传一张照片到QQ空间相册(<b>需要申请权限</b>) */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_UPLOAD_PIC;

/** 获取用户QQ空间相册列表(<b>需要申请权限</b>) */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_LIST_ALBUM;

/** 同步分享到QQ空间、腾讯微博 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_ADD_SHARE;

/** 验证是否认证空间粉丝 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_CHECK_PAGE_FANS;

/** 获取登录用户自己的详细信息 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_INFO;

/** 获取其他用户的详细信息 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_OTHER_INFO;

/** 获取会员用户基本信息 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_VIP_INFO;

/** 获取会员用户详细信息 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_VIP_RICH_INFO;

/** 获取用户信息 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_USER_INFO;

/** 移动端获取用户信息 */
FOUNDATION_EXTERN NSString *const kOPEN_PERMISSION_GET_SIMPLE_USER_INFO;



@interface Utility : NSObject

@end

@interface NSObject(addmethods)
// 字体颜色
- (NSMutableAttributedString *)string:(NSString *)str andFirst:(NSInteger)num1 andSecond:(NSInteger)num2 with:(UIColor *)color;
// 纯色图片
- (UIImage *)createImageWithColor:(UIColor *)color;
// 时间戳转时间
- (NSString *)timeStrIntervalSince:(NSString *)timeStamp withModel:(NSString *)dateStr;

// 个人秀模板
- (UIImageView *)imgviewOne:(CGRect)rect and:(NSString *)imgUrlStr and:(NSString *)neme and:(NSString *)monloge withStyle:(NSString *)style;

- (UIImageView *)imageViewTwo:(CGRect)rect andInfoDic:(NSDictionary *)dict withType:(NSString *)type;

- (UIImageView *)imageViewThree:(CGRect)rect andInfoDic:(NSDictionary *)dict withType:(NSString *)type;

- (UIImageView *)imageViewFour:(CGRect)rect andInfoDic:(NSDictionary *)dict withType:(NSString *)type;

- (UIImageView *)imageViewFive:(CGRect)rect andInfoDic:(NSDictionary *)dict withType:(NSString *)type;

- (UIImageView *)imageViewSix:(CGRect)rect andInfoDic:(NSDictionary *)dict withType:(NSString *)type;

- (UIImageView *)imageViewSeven:(CGRect)rect withType:(NSString *)type;

// 判断登录状态
- (BOOL)isLogin;
// 登录或取消登录
- (void)loginOrCancel;
// 价格显示小数点
- (NSString *)removeFloatAllZero:(NSString *)string;
// 两个时间的差
- (NSMutableAttributedString *)remainingTimeMethodAction:(long long)endTime;
// 长度
- (NSInteger)timeLength:(NSUInteger)time;

@end

@interface UIViewController(background)
- (void)addAavigationView:(NSString*)atitle aback:(NSString*)aback;
@end
